<template>
  <div>
    <table>
      <tr
        is="OutTr"
        v-for="(item, index) in goodsArr"
        :key="index"
        :obj="item"
        :index="index"
      ></tr>
    </table>
    <p>All Number:{{ sumNumber }}</p>
  </div>
</template>

<script>
// 1.创建组件 +铺设静态页面+准备数据
// 2.引入组件
import OutTr from "./components/Out";
export default {
  components: {
    OutTr,
  },
  data() {
    return {
      goodsArr: [
        {
          count: 0,
          goodsName: "Watermelon",
        },
        {
          count: 0,
          goodsName: "Banana",
        },
        {
          count: 0,
          goodsName: "Orange",
        },
        {
          count: 0,
          goodsName: "Pineapple",
        },
        {
          count: 0,
          goodsName: "Strawberry",
        },
      ],
    };
  },
  computed: {
    sumNumber() {
      return this.goodsArr.reduce((sum, obj) => sum += obj.count * 1, 0);
    },
  },
};
</script>

<style>
</style>